package round1B.question1;

import java.util.Scanner;

public class Bate2
{
	private static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args)
	{
		int round = sc.nextInt();
		for(int i=1; i<=round; i++)
		{
			int r = next();
			
			if(r == -1)
			{
				System.out.println("Case #" + i + ": Fegla Won");
			}
			else
			{
				System.out.println("Case #" + i + ": " + r);
			}
		}
	}

	private static int next()
	{
		String[] s = new String[sc.nextInt()];
		
		for(int i=0; i<s.length; i++)
		{
			s[i] = sc.next();
		}
		
		
		int time = 0;
		
		while(check(s))
		{
			char t = s[0].charAt(0);
			int[] squ = new int[s.length];
			
			for(int j=0; j<s.length; j++)
			{
				int c = conn(t,s[j]);
				
				if(c == 0)
					return -1;
				else
				{
					squ[j] = c;
					
					s[j] = s[j].substring(c);
				}
			}
			
			time += Math.abs(squ[0] - squ[1]);
		}
		
		return time;
	}

	private static boolean check(String[] s)
	{
		for(String a : s)
		{
			if(a.length() > 0)
				return true;
		}
		
		return false;
	}

	private static int conn(char t, String a)
	{
		int i=0;
		for(;i<a.length(); i++)
		{
			if(a.charAt(i) != t)
				break;
		}
		
		return i;
	}
}
